import {Injectable} from "@angular/core";
import {Subject} from 'rxjs/Subject';


@Injectable()
export class DialogService {

    private dialogSource = new Subject<DialogTemplate>();

    dialog$ = this.dialogSource.asObservable();

    pushDialogMsg(options: DialogOptions, callback?: () => void) {
        if (callback) {
            this.dialogSource.next({dialogOption: options, callback: callback});
        } else {
            this.dialogSource.next({dialogOption: options});
        }
    }
}

export class DialogTemplate {
    dialogOption: DialogOptions;
    callback?: () => void;
}

export class DialogOptions {
    /**
     * copied from fields of weUIDialog
     */
    /**
     * ActionSheet弹出模式，取值：ios(Ios模式) - 从底部上弹，md(Android模式) - 弹出在窗口中间。默认为ios。
     */
    mode?: string;
    /**
     * 标题
     */
    title?: string;
    /**
     * 内容
     */
    content: string;
    /**
     * @i18n 取消
     */
    btnNOText?: string;
    /**
     * @i18n 确定
     */
    btnOKText?: string;
    /**
     * 是否显示“取消”按钮
     */
    showNOButton?: boolean;

}


